import 'package:google_maps_flutter/google_maps_flutter.dart';

class ParkM {
  ParkM({
    this.id,
    this.groupName,
    this.addr,
    this.lng,
    this.lat,
    this.imgUrl,
    this.radius,
    this.tel,
    this.operater,
    this.operatorId,
    this.enable,
    this.groupType,
    this.groupSpec,
    this.level,
    this.maxQty,
    this.minQty,
    this.definedAreaId,
    this.areaId,
    this.brandCode,
    this.pointsDensity,
    this.currentCount,
    this.districtId,
    this.vehAngle,
    this.vehAngleControl,
    this.isStandardPark,
    this.polygonPoints,
    this.isRfid,
    this.isWirelessPreciseParking,
    this.isBeacon,
    this.isCameraPark,
    this.cameraParkColor,
    this.beaconType,
    this.beaconRssi,
    this.distance,
    this.tags,
    this.bikes,
    this.isAiReturn,
    this.aiAngle,
    this.aiDistance,
    this.isAiotleReturn,
    this.aiotlePlan,
    this.aiotleAngle,
    this.returnParkingSelf,
    this.changeBattery,
    this.openingHours,
    this.openingStatus,
    this.manager,
    this.managerPhone,
    this.outside,
  });

  ParkM.fromJson(dynamic json) {
    id = json['id'];
    groupName = json['group_name'];
    addr = json['addr'];
    lng = json['lng'];
    lat = json['lat'];
    imgUrl = json['img_url'];
    radius = json['radius'];
    tel = json['tel'];
    operater = json['operater'];
    operatorId = json['operator_id'];
    enable = json['enable'];
    groupType = json['group_type'];
    groupSpec = json['group_spec'];
    level = json['level'];
    maxQty = json['max_qty'];
    minQty = json['min_qty'];
    definedAreaId = json['defined_area_id'];
    areaId = json['area_id'];
    brandCode = json['brand_code'];
    pointsDensity = json['points_density'];
    currentCount = json['current_count'];
    districtId = json['district_id'];
    vehAngle = json['veh_angle'];
    vehAngleControl = json['veh_angle_control'];
    isStandardPark = json['is_standard_park'];
    if(json['polygon_points'] != null){
      List<dynamic> poly = json['polygon_points'];
      List<List<LatLng>> m = [];
      for(var item in poly){
        if(item is List && item.isNotEmpty) {
          m.add(item.map((e){
            if(e is List && e.isNotEmpty){
              return LatLng(e.last as double, e.first as double);
            }else{
              return const LatLng(0.0, 0.0);
            }
          }).toList());
        }
      }
      polygonPoints = m;
    }else{
      polygonPoints = [];
    }
    isRfid = json['is_rfid'];
    isWirelessPreciseParking = json['is_wireless_precise_parking'];
    isBeacon = json['is_beacon'];
    isCameraPark = json['is_camera_park'];
    cameraParkColor = json['camera_park_color'];
    beaconType = json['beacon_type'];
    beaconRssi = json['beacon_rssi'];
    distance = json['distance'];
    tags = json['tags'];
    bikes = json['bikes'];
    isAiReturn = json['is_ai_return'];
    aiAngle = json['ai_angle'];
    aiDistance = json['ai_distance'];
    isAiotleReturn = json['is_aiotle_return'];
    aiotlePlan = json['aiotle_plan'];
    aiotleAngle = json['aiotle_angle'];
    returnParkingSelf = json['return_parking_self'];
    changeBattery = json['change_battery'];
    openingHours = json['opening_hours'];
    openingStatus = json['opening_status'];
    manager = json['manager'];
    managerPhone = json['manager_phone'];
    outside = json['outside'];
  }

  String? id;
  String? groupName;
  String? addr;
  double? lng;
  double? lat;
  String? imgUrl;
  int? radius;
  String? tel;
  String? operater;
  String? operatorId;
  int? enable;
  int? groupType;
  int? groupSpec;
  int? level;
  int? maxQty;
  int? minQty;
  String? definedAreaId;
  String? areaId;
  String? brandCode;
  int? pointsDensity;
  int? currentCount;
  String? districtId;
  int? vehAngle;
  int? vehAngleControl;
  int? isStandardPark;
  List<List<LatLng>>? polygonPoints;
  int? isRfid;
  int? isWirelessPreciseParking;
  int? isBeacon;
  int? isCameraPark;
  int? cameraParkColor;
  int? beaconType;
  int? beaconRssi;
  double? distance;
  String? tags;
  int? bikes;
  int? isAiReturn;
  int? aiAngle;
  int? aiDistance;
  int? isAiotleReturn;
  String? aiotlePlan;
  int? aiotleAngle;
  int? returnParkingSelf;
  int? changeBattery;
  String? openingHours;
  int? openingStatus;
  String? manager;
  String? managerPhone;
  int? outside;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['group_name'] = groupName;
    map['addr'] = addr;
    map['lng'] = lng;
    map['lat'] = lat;
    map['img_url'] = imgUrl;
    map['radius'] = radius;
    map['tel'] = tel;
    map['operater'] = operater;
    map['operator_id'] = operatorId;
    map['enable'] = enable;
    map['group_type'] = groupType;
    map['group_spec'] = groupSpec;
    map['level'] = level;
    map['max_qty'] = maxQty;
    map['min_qty'] = minQty;
    map['defined_area_id'] = definedAreaId;
    map['area_id'] = areaId;
    map['brand_code'] = brandCode;
    map['points_density'] = pointsDensity;
    map['current_count'] = currentCount;
    map['district_id'] = districtId;
    map['veh_angle'] = vehAngle;
    map['veh_angle_control'] = vehAngleControl;
    map['is_standard_park'] = isStandardPark;
    map['polygon_points'] = polygonPoints;
    map['is_rfid'] = isRfid;
    map['is_wireless_precise_parking'] = isWirelessPreciseParking;
    map['is_beacon'] = isBeacon;
    map['is_camera_park'] = isCameraPark;
    map['camera_park_color'] = cameraParkColor;
    map['beacon_type'] = beaconType;
    map['beacon_rssi'] = beaconRssi;
    map['distance'] = distance;
    map['tags'] = tags;
    map['bikes'] = bikes;
    map['is_ai_return'] = isAiReturn;
    map['ai_angle'] = aiAngle;
    map['ai_distance'] = aiDistance;
    map['is_aiotle_return'] = isAiotleReturn;
    map['aiotle_plan'] = aiotlePlan;
    map['aiotle_angle'] = aiotleAngle;
    map['return_parking_self'] = returnParkingSelf;
    map['change_battery'] = changeBattery;
    map['opening_hours'] = openingHours;
    map['opening_status'] = openingStatus;
    map['manager'] = manager;
    map['manager_phone'] = managerPhone;
    map['outside'] = outside;
    return map;
  }
}
